{include admin.inc.header}

{include admin.inc.top}

<div class="container-fluid content-body">
	<div class="main">
		{include admin.inc.menu}

		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<ul class="breadcrumb">
					<li>
						<i class="glyphicon glyphicon-home"></i>
						<span>当前位置：</span>
						<a href="#">{$breadcrumb[0]}</a>
						<i class="glyphicon glyphicon-chevron-right"></i>
						<a href="#">{$breadcrumb[1]}</a>
					</li>
				</ul>

				<!-- Nav tabs -->
				<ul class="nav nav-tabs">
					{if $loginUser->hasPermission('admin/user/insert')}
					<li><a href="{$add_url}"><i class="glyphicon glyphicon-plus"></i> 会员注册</a></li>
					{/if}
					<li class="active"><a href="{$index_url}"><i class="glyphicon glyphicon-th-list"></i> 会员列表</a></li>
					<li><a href="javascript:void(0);"><i class="glyphicon glyphicon-edit"></i> 会员编辑</a></li>
				</ul>

				<div class="inner-container">

					<!-- search form start -->
					<form class="form-inline form-search" role="form" id="search-form" autocomplete="off">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-btn">
									<select class="form-control input-sm search-options" name="select_name">
										<option value="username" data-show="#s_sign_status,#s_register_date" {if $params[select_name]=='username'}selected{/if}>会员号</option>
										<option value="name" data-show="#s_sign_status,#s_register_date" {if $params[select_name]=='name'}selected{/if}>联系人</option>
									</select>
								</div><!-- /btn-group -->
								<input  type="text" name="username" value="{$params[$params['select_name']]}" class="form-control input-sm">
							</div>
						</div>
						<div class="form-group" id="s_sign_status">
							<div class="input-group">
								<div class="input-group-addon">签约状态</div>
								<select class="form-control input-sm" name="sign_status">
									<option value="-1">全部</option>
									{loop $signStatus $key $val}
									<option value="{$key}" {if $params[sign_status]==$key}selected{/if}>{$val}</option>
									{/loop}
								</select>
							</div>
						</div>

						<div class="form-group" id="s_register_date">
							<div class="input-group">
								<div class="input-group-addon">注册时间</div>
								<div class="form-inline">
									<input type="text" name="starttime" value="{$params[starttime]}" class="form-control input-sm mdate" placeholder="开始日期">
									<input type="text" name="endtime" value="{$params[endtime]}" class="form-control input-sm mdate" placeholder="结束日期">
								</div>
							</div>
						</div>

						<button type="submit" class="btn btn-success btn-sm">
							<i class="glyphicon glyphicon-search"></i> 搜索</button>
						{data_export_btn}

					</form><!-- END search form -->

					<form id="J_List_Form" autocomplete="off">
						<div class="table-responsive" style="overflow-x: visible;">
							<table class="table table-bordered table-hover" id="J_List_Table">
								<thead>
								<tr>
									<th width="20"><input type="checkbox" class="icheck check-all" /></th>
									{loop $tableHeader $val}
									<th>{$val}</th>
									{/loop}
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td class="no-records text-center">{$noRecords}</td>
								</tr>
								{/if}
								{loop $items $value}
								<tr>
									<td><input type="checkbox" class="icheck" name="ids[]" value="{$value[id]}" id="checkbox_row_{$value[id]}" /></td>
									<td><label for="checkbox_row_{$value[id]}">{$value[username]}</label></td>
									<td>{expr $value[type]==2?'企业':'个人'}</td>
									<td>{$value[contacter]}</td>
									<td>
										{if $value[ischecked]==0}
										<span class="label label-default">未申请</span>
										{elseif $value[ischecked]==1}
										<span class="label label-info">未审核</span>
										{elseif $value[ischecked]==2}
										<span class="label label-success" data-toggle="tooltip" data-html="true"
											  title="审核人：{$managers[$value[checker]][name]} <br/> 审核时间：{$value[checktime]}">已通过</span>
										{elseif $value[ischecked]==3}
										<span class="label label-danger" data-toggle="tooltip" data-html="true"
											  title="审核人：{$managers[$value[checker]][name]} <br/> 审核时间：{$value[checktime]}">未通过</span>
										{/if}

									</td>

									<td>
										{if $value[sign_status]==0}
										<span class="label label-default">未签约</span>
										{elseif $value[sign_status]==1}
										<span class="label label-success">已签约</span>
										{elseif $value[sign_status]==2}
										<span class="label label-danger">已解约</span>
										{/if}
									</td>

									<td>
										<input type="checkbox" data-id="{$value[id]}" data-field="status" class="bswitch bswitch-list" data-size="mini"
											   {if $value[status]==1}checked{/if} data-on-text="启用" data-off-text="禁用">
									</td>
									<td>{$value[checktime]}</td>
									<td>{$value[addtime]}</td>

									<td>
										<div class="btn-group">
											<a href="{$edit_url}/?id={$value[id]}"  class="btn btn-primary btn-xs item-edit">
												<i class="glyphicon glyphicon-edit"></i> 编辑</a>
											<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown">
												<span class="caret"></span>
											</button>
											<ul class="dropdown-menu dropdown-menu-right" role="menu">
												{if ($value[ischecked]==1 || $value[ischecked]==3) && $loginUser->hasPermission('admin/user/doCheck')}
												<li><a href="/admin/user/check/?id={$value[id]}"><i class="glyphicon glyphicon-check"></i> 认证审核</a></li>
												{/if}
												<!-- 认证通过且未签约的用户才显示签约银行 -->
												{if  $value[sign_status]!=1 && $value[ischecked] == 2 && $loginUser->hasPermission('admin/user/doSign')}
												<li><a href="#" class="sign-bank" data-id="{$value[id]}"><i class="glyphicon glyphicon-pencil"></i> 银行签约</a></li>
												{/if}
												{if $loginUser->hasPermission('admin/user/modifyPass')}
												<li><a href="#" class="modify-pass" data-id="{$value[id]}"><i class="glyphicon glyphicon-lock"></i> 修改密码</a></li>
												{/if}

												{if $loginUser->hasPermission('admin/user/modifyMobile')}
												<li><a href="#" class="modify-mobile" data-id="{$value[id]}"><i class="glyphicon glyphicon-edit"></i> 修改会员名</a></li>
												{/if}
											</ul>
										</div>
									</td>
								</tr>
								{/loop}
								</tbody>
							</table>
						</div>
					</form>

					<div class="text-right">
						{$pagemenu}
					</div>

				</div>

			</div><!-- end of inner -->
		</section>

	</div>
</div>

{include admin.inc.footer}

<script type="text/html" id="modify-mobile-template">
	<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 新会员号</label>
				<input type="text" name="username" dtype="mobile" class="form-control" maxlength="15" placeholder="新会员号" required />
			</div>
			<p class="help-block">请输入手机号码</p>
		</div>

		<input type="hidden" name="id" value="{[item.id]}">
	</form>
</script>

<script type="text/html" id="modify-pass-template">
	<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 新密码</label>
				<input type="password" name="password" class="form-control" id="password" handler="__checkPass(value, ele)" min-length="6" maxlength="20" placeholder="新密码" required />
			</div>
			<p class="help-block">请输入6-20位的密码</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 确认密码</label>
				<input type="password" dtype="repass" for-password="password" class="form-control" min-length="6" maxlength="20" placeholder="确认密码" required />
			</div>
			<p class="help-block">请输入6-20位的密码</p>
		</div>

		<input type="hidden" name="id" value="{[item.id]}">
	</form>
</script>

<script>
	function __checkPass(value, ele) {
		if ( /^\d+$/.test(value) ) {
			$(ele).parent().next().addClass("text-error").html('密码不能为纯数字');
			ele.focus();
			return false;
		}
		if ( /^[a-z|a-z]+$/.test(value) ) {
			$(ele).parent().next().addClass("text-error").html('密码不能为纯字母');
			ele.focus();
			return false;
		}
		return true;
	}
</script>

<script type="text/html" id="sign-bank-template">
	<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">

		{if $payways}
		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 支付通道</label>
				<div>
					{loop $payways $value}
					<img src="{$value[icon]}" data-payway="{$value[id]}" style="max-width: 150px;" class="img-thumbnail {[if item.payway=='{$value[id]}']}selected{[/if]}">
					{/loop}
					<input type="hidden" name="data[payway]" value="{[if item.payway!=0]}{[item.payway]}{[/if]}" empty-message="请选择支付通道" required>
				</div>
			</div>
			<p class="help-block">支付通道对应了不同的银行接口</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 户名</label>
				<input type="text" class="form-control"  value="{[item.virtual_name]}" placeholder="户名" readonly/>
			</div>
			<p class="help-block">您只能绑定与实名认证信息一致的银行卡</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 银行卡号</label>
				<input type="text" name="data[card_no]" dtype="number" value="{[item.card_no]}" class="form-control" maxlength="25" min-length="9" placeholder="银行卡号" required />
			</div>
			<p class="help-block">填入使用实名认证的身份证开户的银行卡号(9-25位)</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 开户银行</label>
				<div class="input-group">
					<input type="text" name="data[sign_bank_branch]" value="{[item.sign_bank_branch]}" class="form-control" placeholder="请选择开户银行" readonly />
					<span class="input-group-btn">
						<button class="btn btn-info select-bank" type="button">选择银行</button>
					</span>
				</div>
				<input type="hidden" name="data[sign_bank_code]" value="{[item.sign_bank_code]}" empty-message="请选择开户银行" required />
				<input type="hidden" name="data[sign_bank_id]" value="{[item.sign_bank_id]}" empty-message="请选择开户银行" required />
			</div>
			<p class="help-block"></p>
		</div>

		<input type="hidden" name="id" value="{[item.id]}">
	</form>
	{else}
	<div class="alert alert-danger" role="alert">
		<a href="#" class="alert-link">没有可用银行支付通道，请先去 <a href="/admin/payway/index">配置支付通道</a></a>
	</div>
	{/if}
</script>

<script type="text/html" id="bank-query-template">
	<form role="form" class="content-add-form">

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 选择银行</label>
				<select class="form-control" id="sign_bank_id">
					{loop $banks $value}
					<option value="{$value[id]}">{$value[name]}</option>
					{/loop}
				</select>

			</div>
			<p class="help-block"></p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 选择城市</label>
				<div class="form-inline area-select" id="bank-area-select"></div>
			</div>
			<p class="help-block">选择城市后会自动加载该城市的银行支行</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 选择支行</label>
				<div class="input-group">
					<input type="text" id="branch-keyword" class="form-control" placeholder="请输入支行关键字" required />
					<span class="input-group-btn">
						<button class="btn btn-success" type="button"  id="query">查询</button>
					</span>
				</div>
			</div>
			<p class="help-block">输入支行关键字查询，并在查询结果列表中选择支行</p>
		</div>

		<div class="form-element">
			<div id="bank-list" style="height: 200px; overflow: auto;">

			</div>
		</div>

	</form>
</script>

<script type="text/html" id="bank-list-template">
	<table class="table table-hover">
		{[each items as value]}
		<tr style="cursor: pointer;">
			<td data-code="{[value.number]}">{[value.name]}</td>
		</tr>
		{[/each]}
	</table>
</script>



<script>
	seajs.use("user", function(exports) {
		var configs = {
			set_url : '/admin/user/set/',
			modifyMobile_url : '/admin/user/modifyMobile/',
			modifyPass_url : '/admin/user/modifyPass/',
			signBank_url : '/admin/user/signBank/'
		};
		exports.init(configs);
		exports.modifyMobile(configs);
		exports.modifyPass(configs);
	});

	seajs.use('signBank', function(exports) {

		var configs = {
			signBank_url : '/admin/user/signBank/',
			dosignBank_url : '/admin/user/dosignBank/'
		};
		exports.init(configs);

	});
</script>
</body>
</html>
